//
// amapServer.js
// hs-admin
//
// Created by 区区电脑 on 2023/05/15.
//



import axios from "axios"

export default function aMapServer({url,method, params, data}) {
    const fullUrl = url + "?" + getQuery(params)
    return axios({
        url: fullUrl,
        method: method,
        data: data,
        timeout: 20000,
    }).then(({data}) => data)
}

// 组装 query
export function getQuery(params) {
    let queryArray = [];
    for (let key in params) {
        const value = params[key];
        if (value != undefined) {
            queryArray.push(key + "=" + value);
        }
    }
    const query = queryArray.join("&");
    return query;
}
